<?php
include $this->Render('header.php');
?>
<link rel="stylesheet" type="text/css" href="<?php echo BASE_STYLE;?>/css/admin.css" />
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/uploadifive/jquery.uploadifive.js"></script>
<style type="text/css">
	.daish-box {height:500px;overflow-y:scroll;overflow-x:hidden;width: 640px;padding-left: 44px;padding-top: 15px;color: #444444;margin-left:0;margin-top:0;}
	.danbaoren-box table tr td {padding-bottom:10px;}
	
	.uploadifive-button {width:84px;height:84px !important;line-height:normal;margin-top:-84px;background:none !important;}
	
	.file-upload-completed,.uploadifive-queue-item {position:absolute;width:84px;bottom:0;}
	
	.uploadifive-queue-item .close {background: url('<?php echo BASE_STYLE;?>/uploadifive/uploadifive-cancel.png') 0 0 no-repeat;display: block;float: right;height: 16px;
text-indent: -9999px;width: 16px;}
	.uploadifive-queue-item .progress {height: 3px;margin-top: 5px;width: 100%;}
	.uploadifive-queue-item .progress-bar {background-color: #0072BC;height: 3px;width: 0;}
	
	.uploadifive-queue-item .filename {display:none;}
	
	input[type="text"],select {background:none;}
	
	.dingdan-kehu-box {width:100%; height:auto; overflow:hidden;}
	.dingdan-kehu-box li {float:left; margin-left:15px;}
	.upload-img a {margin-right:10px;}
</style>
<form action="/order/troexp/option/expsave/" method="post" enctype="multipart/form-data" name="form1" class="J-ajaxForm" id="form1">
<div class="daish-box">
	<div class="danbaoren-box">
    	<div class="J-danbaoren-list">
            <div class="J-danbao-data">
            	<table class="J-danbaoren" width="100%" cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td colspan="2" height="40px">快递单号：
                            <input name="ls_express_no" type="text" value="<?php echo $this->data['ls_express_no'];?>" />
                        </td>
                        
                    </tr>
                    <tr>
                    	<td colspan="2">上传照片：</td>
                    </tr>
                    <tr>
                        <td class="J-box-order-family" width="100px">
                        	
                            <div class="file-upload-box J-file-upload-box fn-left mr10">
                                <div class="file-upload-completed" id="J_order_express"></div>
                                <img src="<?php echo BASE_STYLE;?>/images/btn_upload_pic.png" />
                                <input type="file" id="upload_order_express" name="upload-pic" size="30" hidefocus="true" multiple='false' accept="image/*"/>
                            </div>
                        </td>
                        <td class="J-box-order-list-family upload-img">
                        	
                            <?php if(!empty($this->data['ls_express_image'])) foreach($this->data['ls_express_image'] as $k=>$v){?>
                            <a href="javascript:;" style="position:relative; display:inline-block; width:80px; height:80px;">
                                <em class="ico-close J-ico-close"></em>
                                <img src="<?php echo $v;?>" width="80" height="80" />
                                <input type="hidden" value="<?php echo $v;?>" name="ls_express_image[]" />
                            </a>
                            <?php
                            }
                            ?>
                            
                        </td>
                    </tr>
                    <tr>
                    	<td colspan="2" height="15px"></td>
                    </tr>
                    <tr>
                    	<td valign="top">选择订单对应客户</td>
                        <td>
                        	<script type="text/javascript">
                            	$(document).ready(function(e) {
                                    $(".J-dingdan-kehu-box").on('change','li',function(){
										if($(this).hasClass('on')){
											$(this).find('span').addClass('ico-checkbox').removeClass('ico-checkbox-on');
											$(this).removeClass('on');	
										}else{
											$(this).find('span').addClass('ico-checkbox-on').removeClass('ico-checkbox');
											$(this).addClass('on');	
										}	
									});
                                });
                            </script>
                        	<ul class="dingdan-kehu-box J-dingdan-kehu-box">
                            	<?php
                                	if(!empty($this->data)) foreach($this->data as $key => $val){
								?>
                                <li>
                                    <label>
                                        <span class="ico-checkbox"></span>
                                        &nbsp;<?php echo $val['ls_uname'];?>
                                        <input type="checkbox" value="<?php echo $val['ls_oid'];?>" style="display:none;" name="ls_oid[]" />
                                    </label>
                                </li>
                                <?php } ?>
                            </ul>
                        </td>
                    </tr>
                </table>

            </div>
        </div>
    </div>
 
    <div style=" height:40px; overflow:hidden; margin-top:20px;">
    	<input type="hidden" name="oid" value="<?php echo $this->oid;?>" />
        <input type="submit" class="btn-submit-blue J-submit fn-left mr10" value="提交" />
        <a href="" class="a-btn-close J-a-btn-close fn-left">关闭</a>
    </div>
</div>
</form>
<!-- 上传图片 -->
<script type="text/javascript">
<?php $timestamp = time();?>
var names = {'order_express':'.J-box-order-list-family'};
function render_upload() {
	var key;
	for (key in names) {
		$('#upload_' + key).uploadifive({
			'auto': true,
			'multi': false,
			'width': 84,
			'buttonText': '',
			'removeTimeout':1,
			'fileObjName':'upload-pic',
			'formData': {
				'timestamp': '<?php echo $timestamp;?>',
				'tb':key,
				'filebox':'upload-pic',
				'token': '<?php echo md5('unique_salt' . $timestamp);?>'
			},
			'number': key,
			'queueClass':names[key],
			'uploadScript': '/order/upfile/option/upimage/',
			'removeCompleted' : true,
			'onSelect' : function(q, opt){
				//$('#'+opt.formData.key + opt.number).find('a').remove();
			},
			'onUploadComplete': function (file, data, opt) {
					var obj = $.parseJSON(data);

					if (data == 0) {
						alert('您上传的文件不是允许的图片文件！');
						return;
					};
					
					if(obj['success']){
						var html='';
							html+='<a href="javascript:;" style="position:relative; display:inline-block; width:80px;height:80px;">';
							html+='	<em class="ico-close J-ico-close"></em>';
							html+='	<img src="'+obj['msg']['ai_ftpurl']+''+obj['msg']['ai_path']+'" width="80" height="80" />';
							html+='	<input type="hidden" value="'+obj['msg']['ai_path']+'" name="ls_express_image[]" />';
							html+='</a>';

						$(opt.queueClass).append(html);		
					}else{
						Ext.Msg.alert('提示',obj['msg']);
						return false;	
					}

			}
		});
	}
};

$(document).ready(function(e) {
	render_upload();
	
	//删除上传的图片
	$(".J-box-order-list-family").on('click','.J-ico-close',function(){
		$(this).closest('a').remove();	
	});
});
</script>

<script>
	//关闭弹出
	$(".J-a-btn-close").on('click',function(){
		
		var winElement = parent.Ext.fly(window.frameElement).up('div.x-window');
		parent.Ext.getCmp(winElement.id).close();
		
	});
	
	$(document).ready(function(e) {
        $(".J-submit").on('click',function(){
			$(this).dyhlForm({
				beforefunction:chk,
				nofunction:function(){
					$(".J-submit").prop('disabled',false);
				},
				sucessfunction:function(data){
					$(".J-submit").prop('disabled',false);
					if(data['success']){
						Ext.Msg.alert('提示','提交成功',function(){
							var winElement = parent.Ext.fly(window.frameElement).up('div.x-window');
							parent.Ext.getCmp(winElement.id).close();	
						});
						//window.location.reload();
					}else{
						Ext.Msg.alert('提示',data['msg']);
					}
				}	
			});	
		});
    });
	
	function chk(){
		$(".J-submit").prop('disabled',true);	
	}
	
</script>
<?php include $this->Render('footer.php'); ?>
